<?php
require_once 'adminmenu.php';
?>
<div class="well">
    <h4>Top menu:</h4>
    <table class="table table-striped">
        <thead>
            <tr><th>#</th><th>name</th><th>created/modified</th><th>actions</th><th>You owner?</th></tr>
        </thead>
        <tbody>
            <?php
                $content = new Models_Topmenu();
                $topMenu = $content->getTopMenu(' ');
                $subMenues = new Models_Articles();
                //var_dump($topMenu);
                foreach ($topMenu as $value)
                {
                    echo '<tr><td>' 
                            . $value['id'] . '</td><td>|' 
                            . $value['name'] . '</td><td>-</td>
                            <td><a class="btn btn-primary btn-mini" href="/' . $content->path . 'menu/edittop/' . $value[$content->lang . '_article_id'] . '"><i class="icon-pencil icon-white"></i></a>
                            <a class="btn btn-danger btn-mini" href="/"><i class="icon-remove icon-white"></i></a> <a href=\'#\' class="btn btn-mini btn-info"><i class="icon-tag icon-white"></i></a>
                          </td><td>?</td></tr>';
                    $subMenu = $subMenues->getAllSubArticles($value[$content->lang . '_article_id']);
                    foreach ($subMenu as $subValue)
                    {
                        echo '<tr><td>' 
                                . $subValue['id'] . '</td><td>->' 
                                . $subValue['title'] . '</td><td>-</td>
                                <td><a class="btn btn-primary btn-mini" href="/' . $content->path . 'articles/editsub/' . $subValue['id'] . '"><i class="icon-pencil icon-white"></i></a>
                                <a class="btn btn-danger btn-mini" href="#"><i class="icon-remove icon-white"></i></a>
                              </td><td>?</td></tr>';
                    }
                }
            ?>
        </tbody>
    </table>
</div>